approx: expose pytest.Approx as the return type of pytest.approx#14647
Open
bluetech wants to merge 7 commits into
Open
approx: expose pytest.Approx as the return type of pytest.approx#14647bluetech wants to merge 7 commits into
pytest.Approx as the return type of pytest.approx#14647bluetech wants to merge 7 commits into
Conversation
I don't think it has any effect (always False, checked two lines above). Probably a copy/paste error.
Consistently use `_is_bool` check which handles `numpy.bool` in addition to `bool`, instead of `isinstance(..., bool)`.
The code is more direct this way, and more amenable to typing (in follow up commits).
Not really helpful and annoying to type.
This (tries to) improve the typing of the approx code in preparation of exposing a type for its return value. The main change is to make `ApproxBase` generic in the expected value type, so that `self.expected` can have a correct type. This is not so easy...
The `python_api.py` file used to also contain the implementation of `raises`, but that was moved to its own file a while ago. Now `python_api.py` only houses the `approx` code, so let's rename it to the more obvious and less generic `approx.py`.
nicoddemus
approved these changes
Jun 24, 2026
| __hash__ = None # type: ignore | ||
|
|
||
| def __ne__(self, actual) -> bool: | ||
| def __ne__(self, actual: object) -> bool: |
Member
There was a problem hiding this comment.
We can drop this __ne__ implementation, the default implementation (when __eq__ is implemented but __ne__ is not) does exactly this.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As requested in #14164 (part of #7469).
There are some initial commits that are prerequisites or small cleanups/refactors to the code.